package com.sakura.hk.sakura.springboot.plugin.model;

import javax.tools.FileObject;
import javax.tools.ForwardingJavaFileManager;
import javax.tools.JavaFileManager;
import javax.tools.JavaFileObject;
import java.io.IOException;

/**
 * 自定义 java文件管理器
 * @Author: 贺坤
 * @Date: 2021/7/15 14:08
 */
public class ClassJavaFileManager extends ForwardingJavaFileManager {

    private ClassJavaFileObject classJavaFileObject;

    public ClassJavaFileManager(JavaFileManager fileManager) {
        super(fileManager);
    }

    public ClassJavaFileObject getClassJavaFileObject() {
        return classJavaFileObject;
    }

    //这个方法一定要自定义
    @Override
    public JavaFileObject getJavaFileForOutput(Location location, String className, JavaFileObject.Kind kind, FileObject sibling) throws IOException {
        return (classJavaFileObject = new ClassJavaFileObject(className, kind));
    }
}